#pragma once

// c++ redis wrapper.

#include <cpp_redis/cpp_redis>
#include <tacopie/tacopie>

#ifdef _WIN32
#include <Winsock2.h>
#endif /* _WIN32 */

class CDMSocketInit {
public:
    CDMSocketInit() {
    #ifdef _WIN32
        m_version = MAKEWORD(2, 2);
        if (WSAStartup(m_version, &m_data) != 0) {
            std::cerr << "WSAStartup() failure" << std::endl;
            std::exit(-1);
        }
    #endif
    }

    virtual ~CDMSocketInit() {
    #ifdef _WIN32
        WSACleanup();
    #endif
    }

private:
  #ifdef _WIN32
    WORD m_version;
    WSADATA m_data;
  #endif
};

// internal global variable.
static CDMSocketInit g_DMSocketInit;
